﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestUI
{
    public partial class CamControlTest : Form
    {
        public CamControlTest()
        {
            InitializeComponent();
        }

        private void CamControlTest_Load(object sender, EventArgs e)
        {
             cameraBox1.TrackBarBinding(timeLine2);
            //tb2File.DataBindings.Add("Text", timeLine, "Value", false, DataSourceUpdateMode.OnPropertyChanged);
            //timeLine2.DataBindings.Add("Value", tb2File, "Text", false, DataSourceUpdateMode.OnPropertyChanged);
            //Binding b = new Binding("Value", tbCapture, "Text", false, DataSourceUpdateMode.OnPropertyChanged);
            //b.Format += new ConvertEventHandler(b_Format);
            //b.Parse += new ConvertEventHandler(b_Parse);
            //timeLine.DataBindings.Add(b);

        }

        private void butPlay_Click(object sender, EventArgs e)
        {
            cameraBox1.Offline_VideoPlayPath = tbPlayFile.Text;
            cameraBox1.Play();
        }

        private void butPause_Click(object sender, EventArgs e)
        {
            cameraBox1.Pause();
        }

        private void butStop_Click(object sender, EventArgs e)
        {
            //cameraBox1.TrackBarUnbinding(timeLine);
            cameraBox1.Stop();
        }

        private void butRecord_Click(object sender, EventArgs e)
        {
            cameraBox1.StartRecord();
        }

        private void butStopRec_Click(object sender, EventArgs e)
        {
            System.IO.FileInfo finfo = cameraBox1.StopRecord();
            if (finfo != null)
            {
                MessageBox.Show("Successfull record to this file :\r\n    " + finfo.FullName, cameraBox1.Name);
            }
        }

        private void butRec2Folder_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Not implement yet ! This is static call for all cameraBox instance", "Implement soon !");
        }

        private void butRectoFile_Click(object sender, EventArgs e)
        {
            cameraBox1.Online_VideoSavePath = tb2File.Text;
            cameraBox1.StartRecord();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            cameraBox1.Capture(tbCapture.Text);
        }

        private void radOffline_CheckedChanged(object sender, EventArgs e)
        {
            if (radOffline.Checked)
            {
                cameraBox1.CameraMode = SDK10kWrapper.CameraMode.Offline;
                gbOffline.Enabled = true; gbOnline.Enabled = false;
            }
        }

        private void radOnline_CheckedChanged(object sender, EventArgs e)
        {
            if (radOnline.Checked)
            {
                cameraBox1.CameraMode = SDK10kWrapper.CameraMode.Online;
                gbOffline.Enabled = false; gbOnline.Enabled = true;
            }
        }

        private void butBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            DialogResult res = ofd.ShowDialog();
            if (res == System.Windows.Forms.DialogResult.OK)
            {
                tbPlayFile.Text = ofd.FileName;
            }
        }

        private void CamControlTest_FormClosed(object sender, FormClosedEventArgs e)
        {

        }
    }
}